@extends('back.adminbase')
@section('content')
    <section class="hbox stretch">
        @include("back.public.left")
        <aside>
            <section class="vbox">
                <header class="header bg-white b-b clearfix">
                    <form class="talbe-search" method="get" action="{{url('back/ltBook/index')}}">
                        <div class="row m-t-sm">
                            <div class="col-sm-9 m-b-xs">
                            </div>
                            <div class="col-sm-3 m-b-xs">
                                <div class="input-group">
                                    <input class="input-sm form-control" name="keyword" value="{{ old('keyword') }}" placeholder="请输入书名或ISBN码或分类号或条形码" type="text">
                                <span class="input-group-btn">
                                    <button class="btn btn-sm btn-default" type="submit" title="搜索">
                                        <i class="glyphicon glyphicon-search"></i> 搜索
                                    </button>
                                </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </header>
                <section class="scrollable  wrapper w-f">
                    <section class="panel panel-default">
                        <div class="table-responsive">
                            <table class="table table-hover m-b-none entity-view" data-path="/attendance/count/countDetail/id/{0}">
                                <thead>
                                <tr>
                                    <th style="text-align: center;width: 50px">序号</th>
                                    <th style="text-align: center;width: 50px">图片</th>
                                    <th style="text-align: center;width: 50px">ISBN</th>
                                    <th style="text-align: center;width: 100px">书名</th>
                                    <th style="text-align: center;width: 80px">分类号</th>
                                    <th style="text-align: center;width: 80px">数量</th>
                                    <th style="text-align: center;width: 130px">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach ($res as $k=>$v)
                                    <tr>
                                        <td style="text-align: center;">{{$limit*($res->currentPage()-1)+$k+1}}</td>
                                        <td style="text-align: center;">
                                            <img src="@if(empty($v->img)) {{ config('config.picHostPrefix').$v->ImageUrl}} @else {{ config('config.picHostPrefix').$v->img}} @endif" width="80px" height="60px">
                                        </td>
                                        <td style="text-align: center;">{{$v->isbn}}</td>
                                        <td style="text-align: center;">@if(empty($v->Title)) {{$v->cTitle}} @else {{$v->Title}} @endif</td>
                                        <td style="text-align: center;">{{$v->ReqNo}}</td>
                                        <td style="text-align: center;">{{$v->item_count}}</td>
                                        <td style="text-align: center">
                                            <a href="{{ url('back/ltBook/edit/'.$v->ID)}}" class="label label-info">编辑</a>
                                            <a href="{{ url('back/ltBook/secLt/'.$v->ID)}}" class="label label-success">查看</a>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </section>
                    <div>数量：{{$count}}&nbsp;&nbsp;&nbsp;&nbsp;书籍总量：{{$count2}}</div>
                    <div style="text-align: center">{!! $res->appends($_GET)->render() !!}</div>
                </section>

            </section>
        </aside>
    </section>

@endsection

@section('addscript')
    <script>
        $(function(){
            $(".del").click(function(){
                var url=$(this).attr("data-back");

                layer.confirm('您确定删除吗？', {
                    btn: ['确认','取消'] //按钮
                }, function(){
                    $.ajax({
                        'url':url,
                        'type':"get",
                        'dataType':'json',
                        'success':function(data){
                            if(data.success){
                                layer.alert("删除成功！",function(){
                                    location.reload();
                                });
                            }else{
                                layer.alert(data.msg)
                            }
                        }
                    })
                }, function(){

                })
            })
            $(".able").click(function(){
                var id=$(this).data("id");
                var able = $(this).data("able");
                if(able==1) {
                    able=2;
                } else {
                    able=1;
                }
                var mythis = $(this);
                $.ajax({
                    'url':"/admin/scenery/able/"+id+"/"+able,
                    'type':"get",
                    'dataType':'json',
                    'success':function(data){
                        if(data.success){
                            mythis.parent().find('.able').text(data.msg);
                            mythis.parent().find('.able').data('able',data.data);
                            if (data.data==1) {
                                var m ="启用"
                            } else {
                                var m ="禁用"
                            }
                            mythis.parent().parent().find('.status').text(m);
                        }else{
                            layer.alert(data.msg)
                        }
                    }
                })
            })
        });
    </script>
@endsection
